
from selenium import webdriver
import time
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()
driver.get('http://10.59.9.14:7003/')
time.sleep(2)
driver.find_element(By.XPATH,'//a[@href="/home/login.html"]').click()
time.sleep(2)
dy1 = driver.find_element(By.CLASS_NAME,'reg-new').text
print(dy1)
time.sleep(3)
driver.find_element(By.NAME,'username').send_keys('17688889999')
driver.find_element(By.XPATH,'//input[@name="password" and @type="password"]').send_keys('123456')
time.sleep(20)
driver.find_element(By.CLASS_NAME,'finish-btn').click()
time.sleep(3)
dy2 = driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').text
print(dy2)
time.sleep(2)
dy3 = driver.find_element(By.CLASS_NAME,'color-black').text
dy31 = dy3.replace('¥ ','')
print(dy31)
time.sleep(2)
driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a').click()
driver.find_element(By.XPATH,'//input[@class="search-input" or @name="keywords"]').send_keys('音乐耳机')
driver.find_element(By.CLASS_NAME,'search-input-btn').click()
time.sleep(2)
dy4 = driver.find_element(By.XPATH,'/html/body/div[4]/a[2]').text
print(dy4)
driver.find_element(By.XPATH,'//img[@src="/uploads/images/20250712/46f962ff5930582f49d1ad24d95a8b5b.png"]').click()
time.sleep(3)
dy5 = driver.find_element(By.XPATH,'/html/body/div[4]/a[3]').text
print(dy5)
time.sleep(2)
dy6 = driver.find_element(By.ID,'sell-price-box').text
print(dy6)
num = driver.find_element(By.XPATH,'//input[@id="store_nums"]')
time.sleep(2)
num.clear()
time.sleep(2)
num.send_keys('2')
time.sleep(2)
dy7 = num.text
print(dy7)
driver.find_element(By.ID,'add-cart').click()
time.sleep(2)
driver.find_element(By.XPATH,'//a[@href="/home/cart/index.html"]').click()
time.sleep(2)
dy8 = driver.find_element(By.XPATH,'/html/body/div[4]/div[1]/a[2]').text
print(dy8)
driver.find_element(By.XPATH,'//*[@id="cart-box"]/div[1]/table/tbody/tr[3]/td[1]/input').click()
time.sleep(2)
driver.find_element(By.CLASS_NAME,'ask-btn').click()
time.sleep(2)
dy9 = driver.find_element(By.XPATH,'/html/body/div[4]/div[1]/a[2]').text
print(dy9)
driver.find_element(By.ID,'address-54').click()
time.sleep(3)
driver.find_element(By.NAME,'payment').click()
time.sleep(2)
dy10 = driver.find_element(By.ID,'real-freight').text
dy101 = dy10.replace('+','')
print(dy101)
time.sleep(2)

dy11 = driver.find_element(By.ID,'order-amount').text
print(dy11)
time.sleep(2)
assert float(dy7) * float(dy6) + float(dy101) == float(dy11)
time.sleep(3)
driver.find_element(By.ID,'order-button').click()
time.sleep(2)
dy12 = driver.find_element(By.XPATH,'/html/body/div[4]/div[1]/a[2]').text
print(dy12)
time.sleep(2)
dy13 = driver.find_element(By.XPATH,'succe-ico').text
print(dy13)
time.sleep(3)
dy14 = driver.find_element(By.XPATH,'/html/body/div[4]/div[4]/div[2]/ul/li[1]').text
dy141 = dy14.replace('订单编号：','')
time.sleep(3)
dy15 = driver.find_element(By.XPATH,'/html/body/div[4]/div[4]/div[2]/ul/li[2]').text
dy151 = dy15.replace('订单金额：￥','')

assert float(dy151) == float(dy11)

time.sleep(2)
driver.find_element(By.CLASS_NAME,'immediate-pay').click()
time.sleep(3)

dy16 = driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div/div[2]/table[2]/tbody/tr[2]/td[2]').text
print(dy16)


assert dy16 == dy141